<?php

namespace App\Providers;
use App\Facades\Site ;
use App\Models\Admin\AreaStation;
use App\Models\Admin\MenuNavigation;
use Illuminate\Support\ServiceProvider;
use Cache;

class NavServiceProvider extends ServiceProvider{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot(){
        if (Cache::has('menu_nav')) {
            $menuNav = Cache::get('menu_nav');
        }else{
            $menuNav = MenuNavigation::select('id','nav_name','nav_url','nav_sort')->get();
            $menuNav = setSort($menuNav,'nav_sort');
            Cache::forever('menu_nav', $menuNav);
        }
        view()->share('menuNav',$menuNav);

        if (Cache::has('areaStation')) {
            $areaStation = Cache::get('areaStation');
        }else{
            $areaStation = AreaStation::select('station_domain', 'station_sign', 'station_name','station_sort')->get();
            $areaStation = setSort($areaStation,'station_sort');
            Cache::forever('areaStation', $areaStation);
        }
        view()->share('areaStation',$areaStation);
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register(){
    }
}
